Change in openvpn[master]: Change internal id of packet id to uint64
A message that is not in the archive (sent off-list or not yet received): gerrit.1731290343000.If470af2eb456b2b10f9f2806933e026842188c42@...2715...
Attention is currently required from: flichtenheld.
Hello flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/802?usp=email
to review the following change.
Change subject: Change internal id of packet id to uint64
......................................................................
Change internal id of packet id to uint64
This allows to get rid of multiple casts and also prepares for the larger packet id used by epoch data format.
---
M src/openvpn/packet_id.c
M src/openvpn/packet_id.h
M tests/unit_tests/openvpn/test_packet_id.c
3 files changed, 55 insertions(+), 59 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/02/802/1
src/openvpn/packet_id.c +20 -20
@@ -36,6 +36,8 @@#include "syshead.h" +#include <stddef.h> +#include "packet_id.h" #include "misc.h" #include "integer.h"
@@ -56,7 +58,7 @@const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, - int value); + packet_id_print_type value);#endif /* ENABLE_DEBUG */
@@ -65,7 +67,7 @@const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, - int value) + uint64_t value) { #ifdef ENABLE_DEBUG if (unlikely(check_debug_level(msglevel)))
@@ -115,22 +117,21 @@const time_t local_now = now;if (p->seq_list) { -packet_id_type diff; +int64_t diff;/* -* If time value increases, start a new -* sequence number sequence. +* If time value increases, start a new sequence number sequence. */ if (!CIRC_LIST_SIZE (p->seq_list) || pin->time > p->time - || (pin->id >= (packet_id_type )p->seq_backtrack - && pin->id - (packet_id_type )p->seq_backtrack > p->id)) + || (pin->id >= p->seq_backtrack + && pin->id - p->seq_backtrack > p->id)) { p->time = pin->time; p->id =0 ; -if (pin->id > (packet_id_type )p->seq_backtrack) +if (pin->id > p->seq_backtrack) { - p->id = pin->id - (packet_id_type )p->seq_backtrack; + p->id = pin->id - p->seq_backtrack; }CIRC_LIST_RESET (p->seq_list); }
@@ -146,7 +147,7 @@ } diff = p->id - pin->id; -if (diff < (packet_id_type )CIRC_LIST_SIZE (p->seq_list) +if (diff <CIRC_LIST_SIZE (p->seq_list) && local_now >SEQ_EXPIRED ) {CIRC_LIST_ITEM (p->seq_list, diff) = local_now;
@@ -170,9 +171,8 @@const time_t local_now = now;if (p->time_backtrack) { -int i;bool expire = false; -for (i =0 ; i <CIRC_LIST_SIZE (p->seq_list); ++i) +for (int i =0 ; i <CIRC_LIST_SIZE (p->seq_list); ++i) {const time_t t =CIRC_LIST_ITEM (p->seq_list, i);if (t ==SEQ_EXPIRED )
@@ -200,7 +200,7 @@ packet_id_test(struct packet_id_rec *p, const struct packet_id_net *pin) { - packet_id_type diff; + uint64_t diff;packet_id_debug (D_PID_DEBUG , p, pin,"PID_TEST" ,0 );
@@ -231,9 +231,9 @@ diff = p->id - pin->id;/* keep track of maximum backtrack seen for debugging purposes */ -if ((int )diff > p->max_backtrack_stat) +if (diff > p->max_backtrack_stat) { - p->max_backtrack_stat = (int )diff; + p->max_backtrack_stat = diff;packet_id_debug (D_PID_DEBUG_LOW , p, pin,"PID_ERR replay-window backtrack occurred" , p->max_backtrack_stat); }
@@ -557,7 +557,7 @@const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, - int value) + packet_id_print_type value) { struct gc_arena gc = gc_new();struct buffer out =alloc_buf_gc (256 , &gc);
@@ -569,7 +569,7 @@CLEAR (tv);gettimeofday (&tv,NULL ); -buf_printf (&out,"%s [%d]" , message, value); +buf_printf (&out,"%s [" packet_id_format"]" , message, value);buf_printf (&out," [%s-%d] [" , p->name, p->unit);for (i =0 ; sl !=NULL && i < sl->x_size; ++i) {
@@ -604,17 +604,17 @@ }buf_printf (&out,"%c" , c); } -buf_printf (&out,"] %" PRIi64":" packet_id_format, (int64_t )p->time, (packet_id_print_type )p->id); +buf_printf (&out,"] %" PRIi64":" packet_id_format, (int64_t )p->time, p->id);if (pin) { -buf_printf (&out," %" PRIi64":" packet_id_format, (int64_t )pin->time, (packet_id_print_type )pin->id); +buf_printf (&out," %" PRIi64":" packet_id_format, (int64_t )pin->time, pin->id); }buf_printf (&out," t=%" PRIi64"[%d]" , (int64_t )prev_now, (int )(prev_now - tv.tv_sec)); - buf_printf(&out, " r=[%d,%d,%d,%d,%d]", + buf_printf(&out, " r=[%d,%" PRIu64 ",%d,%" PRIu64 ",%d]", (int)(p->last_reap - tv.tv_sec), p->seq_backtrack, p->time_backtrack,
src/openvpn/packet_id.h +25 -31
101 lines not on this page · raw message
tests/unit_tests/openvpn/test_packet_id.c +10 -8
@@ -90,8 +90,8 @@ now =5010 ;assert_true (packet_id_write (&data->pis, &data->test_buf, true, false)); -assert (data->pis.id ==1 ); -assert (data->pis.time == now); +assert_int_equal (data->pis.id,1 ); +assert_int_equal (data->pis.time, now);assert_true (data->test_buf_data.buf_id ==htonl (1 ));assert_true (data->test_buf_data.buf_time ==htonl ((uint32_t )now)); }
@@ -117,8 +117,8 @@ data->test_buf.offset =sizeof (data->test_buf_data); now =5010 ;assert_true (packet_id_write (&data->pis, &data->test_buf, true, true)); -assert (data->pis.id ==1 ); -assert (data->pis.time == now); +assert_int_equal (data->pis.id,1 ); +assert_int_equal (data->pis.time, now);assert_true (data->test_buf_data.buf_id ==htonl (1 ));assert_true (data->test_buf_data.buf_time ==htonl ((uint32_t )now)); }
@@ -128,7 +128,8 @@ {struct test_packet_id_write_data *data = *state; - data->pis.id = ~0 ; +/* maximum 32-bit packet id */ + data->pis.id = (packet_id_type)(~0 );assert_false (packet_id_write (&data->pis, &data->test_buf, false, false)); }
@@ -137,7 +138,8 @@ {struct test_packet_id_write_data *data = *state; - data->pis.id = ~0 ; +/* maximum 32-bit packet id */ + data->pis.id = (packet_id_type)(~0 ); data->pis.time =5006 ;/* Write fails if time did not change */
@@ -148,8 +150,8 @@ now =5010 ;assert_true (packet_id_write (&data->pis, &data->test_buf, true, false)); -assert (data->pis.id ==1 ); -assert (data->pis.time == now); +assert_int_equal (data->pis.id,1 ); +assert_int_equal (data->pis.time, now);assert_true (data->test_buf_data.buf_id ==htonl (1 ));assert_true (data->test_buf_data.buf_time ==htonl ((uint32_t )now)); }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/802?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If470af2eb456b2b10f9f2806933e026842188c42
Gerrit-Change-Number: 802
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld, plaisthos.
stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/802?usp=email )
Change subject: Change internal id of packet id to uint64
......................................................................
Patch Set 5: Code-Review+1
(1 comment)
File src/openvpn/packet_id.c:
http://gerrit.openvpn.net/c/openvpn/+/802/comment/a02d0b38_7ba864df :
PS5, Line 123: * If time value increases, start a new sequence number sequence.
sequence number sequence?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/802?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If470af2eb456b2b10f9f2806933e026842188c42
Gerrit-Change-Number: 802
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 25 Nov 2024 13:13:08 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, stipa.
plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/802?usp=email )
Change subject: Change internal id of packet id to uint64
......................................................................
Patch Set 5:
(1 comment)
File src/openvpn/packet_id.c:
http://gerrit.openvpn.net/c/openvpn/+/802/comment/1a5815f5_02ca1ead :
PS5, Line 123: * If time value increases, start a new sequence number sequence.
Quoted 1 line
sequence number sequence?
This is not a comment that I change but I agree that the wording is not very clear.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/802?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If470af2eb456b2b10f9f2806933e026842188c42
Gerrit-Change-Number: 802
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Sat, 30 Nov 2024 13:01:39 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: stipa <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, plaisthos, stipa.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/802?usp=email )
Change subject: Change internal id of packet id to uint64
......................................................................
Patch Set 8: Code-Review+2
(1 comment)
Patchset:
PS8:
passed all my server/client tests
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/802?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If470af2eb456b2b10f9f2806933e026842188c42
Gerrit-Change-Number: 802
Gerrit-PatchSet: 8
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Wed, 25 Dec 2024 14:17:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v8 1/1 Change internal id of packet id to uint64
In reply to a message not in the archiveFrom: Arne Schwabe <[email protected]...>
This allows to get rid of multiple casts and also prepares for the larger packet id used by epoch data format.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/802
This mail reflects revision 8 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/packet_id.c +20 -20
@@ -36,6 +36,8 @@#include "syshead.h" +#include <stddef.h> +#include "packet_id.h" #include "misc.h" #include "integer.h"
@@ -56,7 +58,7 @@const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, - int value); + packet_id_print_type value);#endif /* ENABLE_DEBUG */
@@ -65,7 +67,7 @@const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, - int value) + uint64_t value) { #ifdef ENABLE_DEBUG if (unlikely(check_debug_level(msglevel)))
@@ -115,22 +117,21 @@const time_t local_now = now;if (p->seq_list) { -packet_id_type diff; +int64_t diff;/* -* If time value increases, start a new -* sequence number sequence. +* If time value increases, start a new sequence number sequence. */ if (!CIRC_LIST_SIZE (p->seq_list) || pin->time > p->time - || (pin->id >= (packet_id_type )p->seq_backtrack - && pin->id - (packet_id_type )p->seq_backtrack > p->id)) + || (pin->id >= p->seq_backtrack + && pin->id - p->seq_backtrack > p->id)) { p->time = pin->time; p->id =0 ; -if (pin->id > (packet_id_type )p->seq_backtrack) +if (pin->id > p->seq_backtrack) { - p->id = pin->id - (packet_id_type )p->seq_backtrack; + p->id = pin->id - p->seq_backtrack; }CIRC_LIST_RESET (p->seq_list); }
@@ -146,7 +147,7 @@ } diff = p->id - pin->id; -if (diff < (packet_id_type )CIRC_LIST_SIZE (p->seq_list) +if (diff <CIRC_LIST_SIZE (p->seq_list) && local_now >SEQ_EXPIRED ) {CIRC_LIST_ITEM (p->seq_list, diff) = local_now;
@@ -170,9 +171,8 @@const time_t local_now = now;if (p->time_backtrack) { -int i;bool expire = false; -for (i =0 ; i <CIRC_LIST_SIZE (p->seq_list); ++i) +for (int i =0 ; i <CIRC_LIST_SIZE (p->seq_list); ++i) {const time_t t =CIRC_LIST_ITEM (p->seq_list, i);if (t ==SEQ_EXPIRED )
@@ -200,7 +200,7 @@ packet_id_test(struct packet_id_rec *p, const struct packet_id_net *pin) { - packet_id_type diff; + uint64_t diff;packet_id_debug (D_PID_DEBUG , p, pin,"PID_TEST" ,0 );
@@ -231,9 +231,9 @@ diff = p->id - pin->id;/* keep track of maximum backtrack seen for debugging purposes */ -if ((int )diff > p->max_backtrack_stat) +if (diff > p->max_backtrack_stat) { - p->max_backtrack_stat = (int )diff; + p->max_backtrack_stat = diff;packet_id_debug (D_PID_DEBUG_LOW , p, pin,"PID_ERR replay-window backtrack occurred" , p->max_backtrack_stat); }
@@ -557,7 +557,7 @@const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, - int value) + packet_id_print_type value) { struct gc_arena gc = gc_new();struct buffer out =alloc_buf_gc (256 , &gc);
@@ -569,7 +569,7 @@CLEAR (tv);gettimeofday (&tv,NULL ); -buf_printf (&out,"%s [%d]" , message, value); +buf_printf (&out,"%s [" packet_id_format"]" , message, value);buf_printf (&out," [%s-%d] [" , p->name, p->unit);for (i =0 ; sl !=NULL && i < sl->x_size; ++i) {
@@ -604,17 +604,17 @@ }buf_printf (&out,"%c" , c); } -buf_printf (&out,"] %" PRIi64":" packet_id_format, (int64_t )p->time, (packet_id_print_type )p->id); +buf_printf (&out,"] %" PRIi64":" packet_id_format, (int64_t )p->time, p->id);if (pin) { -buf_printf (&out," %" PRIi64":" packet_id_format, (int64_t )pin->time, (packet_id_print_type )pin->id); +buf_printf (&out," %" PRIi64":" packet_id_format, (int64_t )pin->time, pin->id); }buf_printf (&out," t=%" PRIi64"[%d]" , (int64_t )prev_now, (int )(prev_now - tv.tv_sec)); - buf_printf(&out, " r=[%d,%d,%d,%d,%d]", + buf_printf(&out, " r=[%d,%" PRIu64 ",%d,%" PRIu64 ",%d]", (int)(p->last_reap - tv.tv_sec), p->seq_backtrack, p->time_backtrack,
src/openvpn/packet_id.h +25 -31
101 lines not on this page · raw message
tests/unit_tests/openvpn/test_packet_id.c +10 -8
@@ -90,8 +90,8 @@ now =5010 ;assert_true (packet_id_write (&data->pis, &data->test_buf, true, false)); -assert (data->pis.id ==1 ); -assert (data->pis.time == now); +assert_int_equal (data->pis.id,1 ); +assert_int_equal (data->pis.time, now);assert_true (data->test_buf_data.buf_id ==htonl (1 ));assert_true (data->test_buf_data.buf_time ==htonl ((uint32_t )now)); }
@@ -117,8 +117,8 @@ data->test_buf.offset =sizeof (data->test_buf_data); now =5010 ;assert_true (packet_id_write (&data->pis, &data->test_buf, true, true)); -assert (data->pis.id ==1 ); -assert (data->pis.time == now); +assert_int_equal (data->pis.id,1 ); +assert_int_equal (data->pis.time, now);assert_true (data->test_buf_data.buf_id ==htonl (1 ));assert_true (data->test_buf_data.buf_time ==htonl ((uint32_t )now)); }
@@ -128,7 +128,8 @@ {struct test_packet_id_write_data *data = *state; - data->pis.id = ~0 ; +/* maximum 32-bit packet id */ + data->pis.id = (packet_id_type)(~0 );assert_false (packet_id_write (&data->pis, &data->test_buf, false, false)); }
@@ -137,7 +138,8 @@ {struct test_packet_id_write_data *data = *state; - data->pis.id = ~0 ; +/* maximum 32-bit packet id */ + data->pis.id = (packet_id_type)(~0 ); data->pis.time =5006 ;/* Write fails if time did not change */
@@ -148,8 +150,8 @@ now =5010 ;assert_true (packet_id_write (&data->pis, &data->test_buf, true, false)); -assert (data->pis.id ==1 ); -assert (data->pis.time == now); +assert_int_equal (data->pis.id,1 ); +assert_int_equal (data->pis.time, now);assert_true (data->test_buf_data.buf_id ==htonl (1 ));assert_true (data->test_buf_data.buf_time ==htonl ((uint32_t )now)); }
[Openvpn-devel] [PATCH applied] Re: Change internal id of packet id to uint64
Stared at the code, took the initial review (+1) from Lev into account, ran on the server/client test bed. Everything looks reasonable, all tests still pass.
Your patch has been applied to the master branch.
commit 5aa7ce4effb58e927945b5162970fa719978658c
Author: Arne Schwabe Date: Wed Dec 25 15:21:31 2024 +0100
Change internal id of packet id to uint64
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30199.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Attention is currently required from: stipa.
cron2 has uploaded a new patch set (#9) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/802?usp=email )
The following approvals got outdated and were removed:
Code-Review+1 by stipa, Code-Review+2 by cron2
Change subject: Change internal id of packet id to uint64
......................................................................
Change internal id of packet id to uint64
This allows to get rid of multiple casts and also prepares for the larger packet id used by epoch data format.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30199.html
---
M src/openvpn/packet_id.c
M src/openvpn/packet_id.h
M tests/unit_tests/openvpn/test_packet_id.c
3 files changed, 55 insertions(+), 59 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/02/802/9
src/openvpn/packet_id.c +20 -20
@@ -36,6 +36,8 @@#include "syshead.h" +#include <stddef.h> +#include "packet_id.h" #include "misc.h" #include "integer.h"
@@ -56,7 +58,7 @@const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, - int value); + packet_id_print_type value);#endif /* ENABLE_DEBUG */
@@ -65,7 +67,7 @@const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, - int value) + uint64_t value) { #ifdef ENABLE_DEBUG if (unlikely(check_debug_level(msglevel)))
@@ -115,22 +117,21 @@const time_t local_now = now;if (p->seq_list) { -packet_id_type diff; +int64_t diff;/* -* If time value increases, start a new -* sequence number sequence. +* If time value increases, start a new sequence number sequence. */ if (!CIRC_LIST_SIZE (p->seq_list) || pin->time > p->time - || (pin->id >= (packet_id_type )p->seq_backtrack - && pin->id - (packet_id_type )p->seq_backtrack > p->id)) + || (pin->id >= p->seq_backtrack + && pin->id - p->seq_backtrack > p->id)) { p->time = pin->time; p->id =0 ; -if (pin->id > (packet_id_type )p->seq_backtrack) +if (pin->id > p->seq_backtrack) { - p->id = pin->id - (packet_id_type )p->seq_backtrack; + p->id = pin->id - p->seq_backtrack; }CIRC_LIST_RESET (p->seq_list); }
@@ -146,7 +147,7 @@ } diff = p->id - pin->id; -if (diff < (packet_id_type )CIRC_LIST_SIZE (p->seq_list) +if (diff <CIRC_LIST_SIZE (p->seq_list) && local_now >SEQ_EXPIRED ) {CIRC_LIST_ITEM (p->seq_list, diff) = local_now;
@@ -170,9 +171,8 @@const time_t local_now = now;if (p->time_backtrack) { -int i;bool expire = false; -for (i =0 ; i <CIRC_LIST_SIZE (p->seq_list); ++i) +for (int i =0 ; i <CIRC_LIST_SIZE (p->seq_list); ++i) {const time_t t =CIRC_LIST_ITEM (p->seq_list, i);if (t ==SEQ_EXPIRED )
@@ -200,7 +200,7 @@ packet_id_test(struct packet_id_rec *p, const struct packet_id_net *pin) { - packet_id_type diff; + uint64_t diff;packet_id_debug (D_PID_DEBUG , p, pin,"PID_TEST" ,0 );
@@ -231,9 +231,9 @@ diff = p->id - pin->id;/* keep track of maximum backtrack seen for debugging purposes */ -if ((int )diff > p->max_backtrack_stat) +if (diff > p->max_backtrack_stat) { - p->max_backtrack_stat = (int )diff; + p->max_backtrack_stat = diff;packet_id_debug (D_PID_DEBUG_LOW , p, pin,"PID_ERR replay-window backtrack occurred" , p->max_backtrack_stat); }
@@ -557,7 +557,7 @@const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, - int value) + packet_id_print_type value) { struct gc_arena gc = gc_new();struct buffer out =alloc_buf_gc (256 , &gc);
@@ -569,7 +569,7 @@CLEAR (tv);gettimeofday (&tv,NULL ); -buf_printf (&out,"%s [%d]" , message, value); +buf_printf (&out,"%s [" packet_id_format"]" , message, value);buf_printf (&out," [%s-%d] [" , p->name, p->unit);for (i =0 ; sl !=NULL && i < sl->x_size; ++i) {
@@ -604,17 +604,17 @@ }buf_printf (&out,"%c" , c); } -buf_printf (&out,"] %" PRIi64":" packet_id_format, (int64_t )p->time, (packet_id_print_type )p->id); +buf_printf (&out,"] %" PRIi64":" packet_id_format, (int64_t )p->time, p->id);if (pin) { -buf_printf (&out," %" PRIi64":" packet_id_format, (int64_t )pin->time, (packet_id_print_type )pin->id); +buf_printf (&out," %" PRIi64":" packet_id_format, (int64_t )pin->time, pin->id); }buf_printf (&out," t=%" PRIi64"[%d]" , (int64_t )prev_now, (int )(prev_now - tv.tv_sec)); - buf_printf(&out, " r=[%d,%d,%d,%d,%d]", + buf_printf(&out, " r=[%d,%" PRIu64 ",%d,%" PRIu64 ",%d]", (int)(p->last_reap - tv.tv_sec), p->seq_backtrack, p->time_backtrack,
src/openvpn/packet_id.h +25 -31
101 lines not on this page · raw message
tests/unit_tests/openvpn/test_packet_id.c +10 -8
@@ -90,8 +90,8 @@ now =5010 ;assert_true (packet_id_write (&data->pis, &data->test_buf, true, false)); -assert (data->pis.id ==1 ); -assert (data->pis.time == now); +assert_int_equal (data->pis.id,1 ); +assert_int_equal (data->pis.time, now);assert_true (data->test_buf_data.buf_id ==htonl (1 ));assert_true (data->test_buf_data.buf_time ==htonl ((uint32_t )now)); }
@@ -117,8 +117,8 @@ data->test_buf.offset =sizeof (data->test_buf_data); now =5010 ;assert_true (packet_id_write (&data->pis, &data->test_buf, true, true)); -assert (data->pis.id ==1 ); -assert (data->pis.time == now); +assert_int_equal (data->pis.id,1 ); +assert_int_equal (data->pis.time, now);assert_true (data->test_buf_data.buf_id ==htonl (1 ));assert_true (data->test_buf_data.buf_time ==htonl ((uint32_t )now)); }
@@ -128,7 +128,8 @@ {struct test_packet_id_write_data *data = *state; - data->pis.id = ~0 ; +/* maximum 32-bit packet id */ + data->pis.id = (packet_id_type)(~0 );assert_false (packet_id_write (&data->pis, &data->test_buf, false, false)); }
@@ -137,7 +138,8 @@ {struct test_packet_id_write_data *data = *state; - data->pis.id = ~0 ; +/* maximum 32-bit packet id */ + data->pis.id = (packet_id_type)(~0 ); data->pis.time =5006 ;/* Write fails if time did not change */
@@ -148,8 +150,8 @@ now =5010 ;assert_true (packet_id_write (&data->pis, &data->test_buf, true, false)); -assert (data->pis.id ==1 ); -assert (data->pis.time == now); +assert_int_equal (data->pis.id,1 ); +assert_int_equal (data->pis.time, now);assert_true (data->test_buf_data.buf_id ==htonl (1 ));assert_true (data->test_buf_data.buf_time ==htonl ((uint32_t )now)); }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/802?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If470af2eb456b2b10f9f2806933e026842188c42
Gerrit-Change-Number: 802
Gerrit-PatchSet: 9
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: stipa.
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/802?usp=email )
Change subject: Change internal id of packet id to uint64
......................................................................
Change internal id of packet id to uint64
This allows to get rid of multiple casts and also prepares for the larger packet id used by epoch data format.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30199.html
---
M src/openvpn/packet_id.c
M src/openvpn/packet_id.h
M tests/unit_tests/openvpn/test_packet_id.c
3 files changed, 55 insertions(+), 59 deletions(-)
src/openvpn/packet_id.c +20 -20
@@ -36,6 +36,8 @@#include "syshead.h" +#include <stddef.h> +#include "packet_id.h" #include "misc.h" #include "integer.h"
@@ -56,7 +58,7 @@const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, - int value); + packet_id_print_type value);#endif /* ENABLE_DEBUG */
@@ -65,7 +67,7 @@const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, - int value) + uint64_t value) { #ifdef ENABLE_DEBUG if (unlikely(check_debug_level(msglevel)))
@@ -115,22 +117,21 @@const time_t local_now = now;if (p->seq_list) { -packet_id_type diff; +int64_t diff;/* -* If time value increases, start a new -* sequence number sequence. +* If time value increases, start a new sequence number sequence. */ if (!CIRC_LIST_SIZE (p->seq_list) || pin->time > p->time - || (pin->id >= (packet_id_type )p->seq_backtrack - && pin->id - (packet_id_type )p->seq_backtrack > p->id)) + || (pin->id >= p->seq_backtrack + && pin->id - p->seq_backtrack > p->id)) { p->time = pin->time; p->id =0 ; -if (pin->id > (packet_id_type )p->seq_backtrack) +if (pin->id > p->seq_backtrack) { - p->id = pin->id - (packet_id_type )p->seq_backtrack; + p->id = pin->id - p->seq_backtrack; }CIRC_LIST_RESET (p->seq_list); }
@@ -146,7 +147,7 @@ } diff = p->id - pin->id; -if (diff < (packet_id_type )CIRC_LIST_SIZE (p->seq_list) +if (diff <CIRC_LIST_SIZE (p->seq_list) && local_now >SEQ_EXPIRED ) {CIRC_LIST_ITEM (p->seq_list, diff) = local_now;
@@ -170,9 +171,8 @@const time_t local_now = now;if (p->time_backtrack) { -int i;bool expire = false; -for (i =0 ; i <CIRC_LIST_SIZE (p->seq_list); ++i) +for (int i =0 ; i <CIRC_LIST_SIZE (p->seq_list); ++i) {const time_t t =CIRC_LIST_ITEM (p->seq_list, i);if (t ==SEQ_EXPIRED )
@@ -200,7 +200,7 @@ packet_id_test(struct packet_id_rec *p, const struct packet_id_net *pin) { - packet_id_type diff; + uint64_t diff;packet_id_debug (D_PID_DEBUG , p, pin,"PID_TEST" ,0 );
@@ -231,9 +231,9 @@ diff = p->id - pin->id;/* keep track of maximum backtrack seen for debugging purposes */ -if ((int )diff > p->max_backtrack_stat) +if (diff > p->max_backtrack_stat) { - p->max_backtrack_stat = (int )diff; + p->max_backtrack_stat = diff;packet_id_debug (D_PID_DEBUG_LOW , p, pin,"PID_ERR replay-window backtrack occurred" , p->max_backtrack_stat); }
@@ -557,7 +557,7 @@const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, - int value) + packet_id_print_type value) { struct gc_arena gc = gc_new();struct buffer out =alloc_buf_gc (256 , &gc);
@@ -569,7 +569,7 @@CLEAR (tv);gettimeofday (&tv,NULL ); -buf_printf (&out,"%s [%d]" , message, value); +buf_printf (&out,"%s [" packet_id_format"]" , message, value);buf_printf (&out," [%s-%d] [" , p->name, p->unit);for (i =0 ; sl !=NULL && i < sl->x_size; ++i) {
@@ -604,17 +604,17 @@ }buf_printf (&out,"%c" , c); } -buf_printf (&out,"] %" PRIi64":" packet_id_format, (int64_t )p->time, (packet_id_print_type )p->id); +buf_printf (&out,"] %" PRIi64":" packet_id_format, (int64_t )p->time, p->id);if (pin) { -buf_printf (&out," %" PRIi64":" packet_id_format, (int64_t )pin->time, (packet_id_print_type )pin->id); +buf_printf (&out," %" PRIi64":" packet_id_format, (int64_t )pin->time, pin->id); }buf_printf (&out," t=%" PRIi64"[%d]" , (int64_t )prev_now, (int )(prev_now - tv.tv_sec)); - buf_printf(&out, " r=[%d,%d,%d,%d,%d]", + buf_printf(&out, " r=[%d,%" PRIu64 ",%d,%" PRIu64 ",%d]", (int)(p->last_reap - tv.tv_sec), p->seq_backtrack, p->time_backtrack,
src/openvpn/packet_id.h +25 -31
101 lines not on this page · raw message
tests/unit_tests/openvpn/test_packet_id.c +10 -8
@@ -90,8 +90,8 @@ now =5010 ;assert_true (packet_id_write (&data->pis, &data->test_buf, true, false)); -assert (data->pis.id ==1 ); -assert (data->pis.time == now); +assert_int_equal (data->pis.id,1 ); +assert_int_equal (data->pis.time, now);assert_true (data->test_buf_data.buf_id ==htonl (1 ));assert_true (data->test_buf_data.buf_time ==htonl ((uint32_t )now)); }
@@ -117,8 +117,8 @@ data->test_buf.offset =sizeof (data->test_buf_data); now =5010 ;assert_true (packet_id_write (&data->pis, &data->test_buf, true, true)); -assert (data->pis.id ==1 ); -assert (data->pis.time == now); +assert_int_equal (data->pis.id,1 ); +assert_int_equal (data->pis.time, now);assert_true (data->test_buf_data.buf_id ==htonl (1 ));assert_true (data->test_buf_data.buf_time ==htonl ((uint32_t )now)); }
@@ -128,7 +128,8 @@ {struct test_packet_id_write_data *data = *state; - data->pis.id = ~0 ; +/* maximum 32-bit packet id */ + data->pis.id = (packet_id_type)(~0 );assert_false (packet_id_write (&data->pis, &data->test_buf, false, false)); }
@@ -137,7 +138,8 @@ {struct test_packet_id_write_data *data = *state; - data->pis.id = ~0 ; +/* maximum 32-bit packet id */ + data->pis.id = (packet_id_type)(~0 ); data->pis.time =5006 ;/* Write fails if time did not change */
@@ -148,8 +150,8 @@ now =5010 ;assert_true (packet_id_write (&data->pis, &data->test_buf, true, false)); -assert (data->pis.id ==1 ); -assert (data->pis.time == now); +assert_int_equal (data->pis.id,1 ); +assert_int_equal (data->pis.time, now);assert_true (data->test_buf_data.buf_id ==htonl (1 ));assert_true (data->test_buf_data.buf_time ==htonl ((uint32_t )now)); }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/802?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If470af2eb456b2b10f9f2806933e026842188c42
Gerrit-Change-Number: 802
Gerrit-PatchSet: 9
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-MessageType: merged